package com.example.cola.client.api.dto;

import lombok.Data;

/**
 * 统一响应对象
 * 
 * @author 资深开发专家
 * @version 1.0
 */
@Data
public class Response<T> {
    
    private boolean success;
    private String message;
    private T data;
    private String code;
    
    public static <T> Response<T> success(T data) {
        Response<T> response = new Response<>();
        response.success = true;
        response.data = data;
        response.message = "操作成功";
        response.code = "200";
        return response;
    }
    
    public static <T> Response<T> success(String message, T data) {
        Response<T> response = new Response<>();
        response.success = true;
        response.data = data;
        response.message = message;
        response.code = "200";
        return response;
    }
    
    public static <T> Response<T> error(String message) {
        Response<T> response = new Response<>();
        response.success = false;
        response.message = message;
        response.code = "500";
        return response;
    }
    
    public static <T> Response<T> error(String code, String message) {
        Response<T> response = new Response<>();
        response.success = false;
        response.message = message;
        response.code = code;
        return response;
    }
}
